import Vue from 'vue'
import VueRouter from 'vue-router'
import Header from '../components/header'
import Footer from '../components/footer'
import Home from '@/views/home'
import Category from '@/views/category'
import Cart from '@/views/cart'
import Mine from '@/views/mine'
import News from '@/views/news'
import Seckill from '@/views/seckill'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    components: {
      header: Header, // 向 header 名称的视图中渲染该组件
      default: Home,
      footer: Footer,
    },
    meta: { // 路由元信息，是在当前路由处理时需要用到的一些额外的数据
      icon: '&#xe751;',
      title: '首页',
      inTabbar: true,
    },
  },
  {
    path: '/category',
    name: 'category',
    components: {
      header: Header,
      default: Category,
      footer: Footer,
    },
    children: [ // 子路由
      {
        path: 'sub',
        meta: {
          title: '子分类',
        },
      },
    ],
    meta: {
      icon: '&#xe790;',
      title: '分类',
      inTabbar: true,
    },
  },
  {
    path: '/cart',
    name: 'cart',
    components: {
      default: Cart,
    },
    meta: {
    },
  },
  {
    path: '/seckill',
    name: 'seckill',
    components: {
      default: Seckill,
      footer: Footer,
    },
    meta: {
      icon: '&#xe600;',
      title: '秒杀',
      inTabbar: true,
    },
  },
  {
    path: '/news',
    name: 'news',
    components: {
      default: News,
      footer: Footer,
    },
    meta: {
      icon: '&#xe763;',
      title: '消息',
      inTabbar: true,
    },
  },
  {
    path: '/mine',
    name: 'mine',
    components: {
      default: Mine,
      footer: Footer,
    },
    meta: {
      icon: '&#xe75e;',
      title: '我的',
      inTabbar: true,
    },
  },
]

export default routes
